1657 permanent fix for parallel organisation lookup - #1212
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough
ChangesfetchOne 404 error propagation change
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/unit/middleware/middleware.builders.test.js`:
- Line 66: The assertion at line 66 (and the similar one at line 176) uses
`toHaveBeenCalledWith(new MiddlewareError(...))` which relies on Error instance
equality that doesn't reliably compare custom properties like statusCode on
Error subclasses. Instead of comparing against a fresh MiddlewareError instance,
change the assertion to explicitly verify that the first argument passed to the
`next` function is a MiddlewareError instance and explicitly assert that its
`message` property equals 'Not found' and its `statusCode` property equals 404.
Apply the same fix to both assertions at line 66 and line 176.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: fd4a325f-422b-453a-8da6-8e9e52dfd3ad
📒 Files selected for processing (2)
src/middleware/middleware.builders.jstest/unit/middleware/middleware.builders.test.js
Description
Fixes a race condition where
FetchOnecould render a 404 response midway through a parallel middleware chain, allowing later middleware to continue and attempt a second response. Missing-recordfetchOneresults now pass aMiddlewareError(404)to the normal error handler, and the LPA overview chain fetches organisation info before parallel work that depends on it.What type of PR is this? (check all applicable)
Related Tickets & Documents
QA Instructions, Screenshots, Recordings
Manual reproduction was confirmed by temporarily restoring the race shape with a delayed parallel sibling. Before the fix, this produced:
After the fix, the same flow no longer crashes and the 404 is handled through the normal middleware error path.
Before
N/A - no UI change. Before fix, non-existent organisation requests could crash with a double-response error.
After
N/A - no UI change. Non-existent organisation requests now return a normal 404 flow.
Added/updated tests?
We encourage you to keep the code coverage percentage at 80% and above.
Added/updated unit coverage for
FetchOnemissing-record handling and a slow siblingparallel()middleware scenario.QA sign off
[optional] Are there any post-deployment tasks we need to perform?
None.
[optional] Are there any dependencies on other PRs or Work?
None.
Summary by CodeRabbit